import { _decorator, CCInteger, CCString, Enum } from 'cc';
import { ISensor, ObservationType } from './ISensor';
import { SensorComponent } from './SensorComponent';
import { VectorSensor } from './VectorSensor';
import { StackingSensor } from './StackingSensor';
const { ccclass, property, menu } = _decorator;


Enum(ObservationType);

@ccclass('VectorSensorComponent')
@menu("ML Agents/Vector Sensor")
export class VectorSensorComponent extends SensorComponent {

    @property(CCString)
    sensorName: string = 'VectorSensor';

    @property(CCInteger)
    observationSize: number = 0;

    @property({ type: ObservationType, serializable: true, visible: true })
    public observationType: ObservationType = ObservationType.Default;

    private _sensor: VectorSensor = null!;

    @property({ range: [1, 50, 1] })
    public observationStacks = 1;


    createSensors(): ISensor[] {
        this._sensor = new VectorSensor(this.observationSize, this.sensorName, this.observationType);
        if (this.observationStacks !== 1) {
            return [new StackingSensor(this._sensor, this.observationStacks)]
        }

        return [this._sensor];
    }

    getSensor(): ISensor {
        return this._sensor;
    }


}